import Vue from 'vue';
import App from './App.vue';
import router from './router/index';
import store from './store/index';

import '@/assets/styles/main.scss';
import '@/assets/styles/ui.css';
// import '@/util/prevent-re-click';

import dayjs from 'dayjs';
Vue.prototype.$dayjs = dayjs;

import auth from './util/auth';
Vue.use(auth);

import cookies from 'vue-cookies';
Vue.use(cookies);

import VueMeta from 'vue-meta';
Vue.use(VueMeta);

import ElementUI from 'element-ui';
import './assets/styles/element-variables.scss';
Vue.use(ElementUI);

import hotkeys from 'hotkeys-js';
Vue.prototype.$hotkeys = hotkeys;

// 全局组件自动注册
import './components/autoRegister';

// 自动加载 svg 图标
const req = require.context('./assets/icons', false, /\.svg$/);
const requireAll = requireContext => requireContext.keys().map(requireContext);
requireAll(req);

import './assets/styles/reset.scss';

// import './mock';

Vue.config.productionTip = false;

Vue.prototype.$eventBus = new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app');

import BMap from 'vue-baidu-map';

Vue.use(BMap, {
    ak: 'Y8AgVEC6ZTFoulULDaBTb548RpuCuqZL'  //  在此输入你自己的百度地图ak
});

import {BmlMarkerClusterer} from 'vue-baidu-map';

Vue.component('BmlMarkerCluster', BmlMarkerClusterer);

import {BmlLushu} from 'vue-baidu-map';

Vue.component('BmlLushu', BmlLushu);

Vue.prototype.validForbid = function(value) {
    value = value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,./;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘’，。、]/g, '').replace(/\s/g, '');
    return value;
};

Vue.prototype.clickTooFast = function() {
    let now = Date.now();
    if (now - (this.last_click_time || 0) > 1000) {
        this.last_click_time = now;
        return false;
    } else {
        console.log('clicktoofast');
        return true;
    }
};
